<?php

add_filter('widget_text', 'do_shortcode');

function do_gallery_carousel ($galeria_nome, $tipo) {	
	include_once TEMPLATEPATH.'/av-define.php';
	include_once PDO.'/NextGenPDO.class.php';
	$ng = new NextGenPDO ();
	$linha = $ng->galeria_get_all_by_name($galeria_nome); 
	$galeria_picture_tudo = $ng->galeria_get_picture_source();

	if ($tipo == 'simple') {?>
		<script type="text/javascript">
		$(document).ready(function(){
		  $('.slider1simple').bxSlider({
		    slideWidth: 100,
		    minSlides: 4,
		    maxSlides: 4,
		    slideMargin: 10,
		    controls: true,
		    pager: false
		  });
		});
		</script>
		<div class="slider1simple"> 
	  	<?php  	
		foreach ($linha as $key => $value) {?>
			<div class="slide">
	  		<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
				<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" width="198px" height="96px" style="margin-bottom: 10px;" />
			</a>	
			</div><!-- Fim div slide-->
		<?php
		}
		?>
		</div>
	<?php
	}
	if ($tipo == 'double') {?>
		<script type="text/javascript">
		$(document).ready(function(){
		  $('.slider1').bxSlider({
		  	slideWidth: 140,
		    minSlides: 4,
		    maxSlides: 4,
		    slideMargin: 10,
		    controls: true,
		    pager: false
		  });
		});
		</script>

		<style type="text/css">
		.bx-viewport{margin: auto;}	
		</style>
		
		<div class="slider1"> 
	  	<?php
	  	$aux_qtde_pictures = 0; 
		foreach ($galeria_picture_tudo as $key => $value) {	
			$aux_qtde_pictures = $aux_qtde_pictures + 1;
			$fotos [] = $value;				  			
		} 
	  	
	  	$aux_grade = 0;
		foreach ($linha as $key => $value) {
			$aux_grade = $aux_grade + 1;
			if ( eh_par($aux_grade) == 0 ) { ?>
				<div class="slide">
		  			<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
						<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" title="<?php echo $value['image_slug']; ?>" width="198px" height="96px" style="margin-bottom: 10px;" />
					</a>
			<?php
			} else { ?>
					<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
						<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" title="<?php echo $value['image_slug']; ?>" width="198px" height="96px" />
					</a>
				</div><!-- Fim div slide-->
			<?php
			}
			if ( eh_par($aux_qtde_pictures) == 0 && ($aux_qtde_pictures - 1 == $aux_grade) ) {
				break;
			}								  								  			
		}  	
	  	?>	
		</div>	
	<?php
	}

}


function do_carousel_publicidade ($galeria_nome) {	
	include_once TEMPLATEPATH.'/av-define.php';
	include_once PDO.'/NextGenPDO.class.php';
	$ng = new NextGenPDO ();
	$linha = $ng->galeria_get_all_by_name($galeria_nome); 
	$galeria_picture_tudo = $ng->galeria_get_picture_source();?>

	<script type="text/javascript">
	$(document).ready(function(){
	  $('.slider1publicidade').bxSlider({
	    slideWidth: 980,
	    minSlides: 5,
	    maxSlides: 5,
	    slideMargin: 10,
	    infiniteLoop: true,
	    controls: true,
	    pager: false
	  });
	});
	</script>
	<div class="slider1publicidade"> 
  	<?php 
	shuffle($linha);	
	foreach ($linha as $key => $value) {?>
		<div class="slide">
			<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
			<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" width="200px" height="110px" />
		</a>	
		</div>
			
		

		
	<?php
	}
	?>
	  		
	</div>
<?php	
}

function do_image_capa ($postID) {?>
	<style type="text/css">
	.capa{margin:auto;width:940px;height:335px;}
	.credito{float:right;font-size:10px;margin:5px 20px auto;}
	</style><div class="vertical_space_20"></div>
	<div class="capa">
  		<a>			
			<?php
			if (have_posts()) : 
			while (have_posts()) : the_post();
				the_post_thumbnail('principal');
   			endwhile; 
			endif; 
			?>
		</a>		
	</div>
	<div><span class="credito cinza10"><?php echo get_post_meta($postID, 'avpt_home_legenda_imagem', true); ?></span></div>
<?php	
}


function do_carousel_publicidade_livros ($galeria_nome) {	
	include_once TEMPLATEPATH.'/av-define.php';
	include_once PDO.'/NextGenPDO.class.php';
	$ng = new NextGenPDO ();
	$linha = $ng->galeria_get_all_by_name($galeria_nome); 
	$galeria_picture_tudo = $ng->galeria_get_picture_source();?>

	<script type="text/javascript">
	$(document).ready(function(){
	  $('.slider1publicidadelivros').bxSlider({
	    slideWidth: 630,
	    minSlides: 7,
	    maxSlides: 7,
	    slideMargin: 8,
	    controls: true,
	    pager: false
	  });
	});
	</script>
	<div class="slider1publicidadelivros"> 
  	<?php  	
	foreach ($linha as $key => $value) {?>
		<div class="slide">
  		<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
			<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" width="82px" height="120px" />
		</a>	
		</div><!-- Fim div slide-->
	<?php
	}
	?>
	</div>
<?php	
}



function do_carousel_destaques_1 ($galeria_nome) {	
	include_once TEMPLATEPATH.'/av-define.php';
	include_once PDO.'/NextGenPDO.class.php';
	$ng = new NextGenPDO ();
	$linha = $ng->galeria_get_all_by_name($galeria_nome); 
	$galeria_picture_tudo = $ng->galeria_get_picture_source();?>



	<script type="text/javascript">
	$(document).ready(function(){
	  $('.slider1destaques1').bxSlider({
	    slideWidth: 650,
	    minSlides: 1,
	    maxSlides: 1,
	    slideMargin: 1,
	    controls: false,
	    captions: true,
	    pager: true
	  });
	});
	</script>
	<style type="text/css">
	.bx-pager bx-default-pager{position: absolute;}
	</style>
	<div class="slider1destaques1" > 
  	<?php  
  	$aux = 0;
  	shuffle($linha);	
	foreach ($linha as $key => $value) {
		$aux = $aux + 1;?>
		
		<div class="slide" style="margin-left:0">
  		<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
  			<div><img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" width="650px" height="300px" 
  				title="Nulla facilisi. Maecenas venenatis arcu id turpis mattis adipiscing. 
  				Mauris sit amet lacus vitae neque tristique venenatis. Suspendisse laoreet ut purus ut suscipit. 
  				Praesent scelerisque tincidunt augue vitae adipiscing" />
  			</div>
  			<!--
  			<div class="clr"></div>
			<div style="width:185px;height:300px;margin-top:-300px;margin-left: 460px">Aquiu vai um texto sbre a Imagem</div>
			-->		
		</a>
				
		</div><!-- Fim div slide--> 
		
			
	<?php
	if($aux>5){break;}

	}
	?>
	</ul>
	</div>
<?php	
}







function testa_pub () {
	?>
	<script type="text/javascript">
	$(document).ready(function(){
	  $('.testa_pub').bxSlider({
	    slideWidth: 940,
	    minSlides: 5,
	    maxSlides: 5,
	    slideMargin: 2,
	    controls: true,
	    pager: false
	  });
	});
	</script>

	<style type="text/css">
	.bx-wrapper .bx-viewport {
	-moz-box-shadow: 0 0 5px #efefef;
	-webkit-box-shadow: 0 0 5px #efefef;
	box-shadow: 0 0 5px #efefef;
	border: solid #efefef 10px;
	left: -5px;
	background: #efefef;	
	}	
	</style>	
	
	<ul class="testa_pub">
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/pub/pub_agroexito.jpg' ?>" width="181px" height="100px" /></li>	  
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/pub/pub_amarzoo.jpg' ?>" width="181px" height="100px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/pub/pub_ararapark.jpg' ?>" width="181px" height="100px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/pub/pub_ornicare.jpg' ?>" width="181px" height="100px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/pub/pub_orniex.jpg' ?>" width="181px" height="100px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/pub/pub_ornipro.jpg' ?>" width="181px" height="100px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/pub/pub_petvendas.jpg' ?>" width="181px" height="100px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/pub/pub_saidacasca.jpg' ?>" width="181px" height="100px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/pub/pub_stabvida.jpg' ?>" width="181px" height="100px"  /></li>
	</ul>


<?php
}




function testa_pub2 () {
	?>
	<script type="text/javascript">
	$(document).ready(function(){
	  $('.testa_pub2').bxSlider({
	    slideWidth: 630,
	    minSlides: 7,
	    maxSlides: 7,
	    slideMargin: 8,
	    controls: true,
	    pager: false
	  });
	});
	</script>

	<style type="text/css">
	.bx-wrapper .bx-viewport {
	-moz-box-shadow: 0 0 5px #efefef;
	-webkit-box-shadow: 0 0 5px #efefef;
	box-shadow: 0 0 5px #efefef;
	border: solid #efefef 5px;
	left: -5px;
	background: #efefef;	
	}	
	</style>	
	
	<ul class="testa_pub2">
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/livros/the-lizard-canary_200.jpg' ?>" width="82px" height="120px" /></li>	  
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/livros/guiadasaves_aquilinoribeiro_200.jpg' ?>" width="82px" height="120px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/livros/agaporniden_deel2e1_200.jpg' ?>" width="82px" height="120px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/livros/razas-de-palomas_200.jpg' ?>" width="82px" height="120px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/livros/the-lizard-canary_200.jpg' ?>" width="82px" height="120px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/livros/9781426209963_200.jpg' ?>" width="82px" height="120px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/livros/9781849491341_200.jpg' ?>" width="82px" height="120px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/livros/9780486283418_200.jpg' ?>" width="82px" height="120px"  /></li>
	  <li><img src="<?php echo get_bloginfo('url').'/'.'wp-content/themes/generic/images/livros/tucanos_das_americas_200.jpg' ?>" width="82px" height="120px"  /></li>
	</ul>


<?php
}


















































function do_gallery_carousel_double ($galeria_nome) {	
	include_once TEMPLATEPATH.'/av-define.php';
	include_once PDO.'/NextGenPDO.class.php';
	$ng = new NextGenPDO ();
	$linha = $ng->galeria_get_all_by_name($galeria_nome); 
	$galeria_picture_tudo = $ng->galeria_get_picture_source();?>	

	<script type="text/javascript">
	$(document).ready(function(){
	  $('.slider1').bxSlider({
	  	slideWidth: 140,
	    minSlides: 4,
	    maxSlides: 4,
	    slideMargin: 10,
	    controls: true,
	    pager: false
	  });
	});
	</script>

	<style type="text/css">
	.bx-viewport{margin: auto;}	
	</style>
	
	<div class="slider1"> 
  	<?php
  	$aux_qtde_pictures = 0; 
	foreach ($galeria_picture_tudo as $key => $value) {	
		$aux_qtde_pictures = $aux_qtde_pictures + 1;
		$fotos [] = $value;				  			
	} 
  	
  	$aux_grade = 0;
	foreach ($linha as $key => $value) {
		$aux_grade = $aux_grade + 1;
		if ( eh_par($aux_grade) == 0 ) { ?>
			<div class="slide">
	  			<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
					<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" title="<?php echo $value['image_slug']; ?>" width="198px" height="96px" style="margin-bottom: 10px;" />
				</a>
		<?php
		} else { ?>
				<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
					<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" title="<?php echo $value['image_slug']; ?>" width="198px" height="96px" />
				</a>
			</div><!-- Fim div slide-->
		<?php
		}
		if ( eh_par($aux_qtde_pictures) == 0 && ($aux_qtde_pictures - 1 == $aux_grade) ) {
			break;
		}								  								  			
	}  	
  	?>	
	</div>
<?php
}


function do_gallery_carousel_simple ($galeria_nome) {	
	include_once TEMPLATEPATH.'/av-define.php';
	include_once PDO.'/NextGenPDO.class.php';
	$ng = new NextGenPDO ();
	$linha = $ng->galeria_get_all_by_name($galeria_nome); 
	$galeria_picture_tudo = $ng->galeria_get_picture_source();?>

	<script type="text/javascript">
	$(document).ready(function(){
	  $('.slider1simple').bxSlider({
	    slideWidth: 100,
	    minSlides: 3,
	    maxSlides: 3,
	    slideMargin: 10,
	    controls: true,
	    pager: false
	  });
	});
	</script>
	<div class="slider1simple"> 
  	<?php  	
	foreach ($linha as $key => $value) {?>
		<div class="slide">
  		<a href="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>">
			<img src="<?php echo get_bloginfo('url').'/'.$value['path'].'/'.$value['filename']; ?>" width="198px" height="96px" style="margin-bottom: 10px;" />
		</a>	
		</div><!-- Fim div slide-->
	<?php
	}
	?>
	</div>
<?php	
}



function botao_shortcode($tipo) {
    extract(shortcode_atts(array(
        'tipo' => 'tipo'
    ), $tipo));
     
    // check what type user entered
    switch ($tipo) {
        case 'twitter':
            return '<a href="http://twitter.com/filipstefansson" class="twitter-button">Follw me on Twitter!</a>';
            break;
        case 'rss':
            return '<a href="http://example.com/rss" class="rss-button">Subscribe to the feed!</a>';
            break;
    }
}
add_shortcode('botao', 'botao_shortcode');



